﻿using Design.Common.Utils;

namespace SingletonPattern
{
    internal sealed class NestedClassSingleton
    {
        private const string _name = "嵌套模式";

        private NestedClassSingleton()
        {
            ConsoleExpansion.WriteLine($"{_name} 创建实例:{Guid.NewGuid()}");
        }

        private class NestedClassInside
        {
            public static readonly NestedClassSingleton Instance = new();
        }

        public static NestedClassSingleton Instance
        {
            get
            {
                ConsoleExpansion.WriteLine($"{_name} 获取实例 is null {NestedClassInside.Instance == null}");

                return NestedClassInside.Instance;
            }
        }
    }
}